<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE HTML>
<html>
<head>
    <title>影视列表</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link href="/static/bui/css/bs3/dpl.css" rel="stylesheet" type="text/css"/>
    <link href="/static/bui/css/bs3/bui.css" rel="stylesheet" type="text/css"/>

</head>

<body>
<div class="content" style="margin: 15px">

    <!-- 搜索页 ================================================== -->
    <div class="row">

        <form id="searchForm" class="form-horizontal" tabindex="0" style="outline: none;">
            <div class="row">
                <div class="control-group span8">
                    <label class="control-label">类型：</label>

                    <div class="controls">
                        <select name="hdType">
                            <option value="">全部</option>
                            <c:forEach var="tt" items="${filmTypes}">
                                <option value="${tt}">${tt}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="control-group span8">
                    <label class="control-label">地区：</label>

                    <div class="controls">
                        <select name="clime">
                            <option value="-2">-全部-</option>
                            <option value="1">内地</option>
                            <option value="2">港台</option>
                            <option value="3">日韩</option>
                            <option value="4">欧美</option>
                            <option value="5">其他</option>
                            <%--<option value="内地">内地</option>--%>
                            <%--<option value="港台">港台</option>--%>
                            <%--<option value="日韩">日韩</option>--%>
                            <%--<option value="欧美">欧美</option>--%>
                            <%--<option value="其他">其他</option>--%>
                        </select>
                    </div>
                </div>
                <div class="control-group span8">
                    <label class="control-label">状态：</label>

                    <div class="controls">
                        <select name="status">
                            <option value="-2">-全部-</option>
                            <option value="0">下线</option>
                            <option value="1">上线</option>
                            <option value="-1">停用</option>
                        </select>
                    </div>
                </div>
                <%--<div class="control-group span8">--%>
                <%--<label class="control-label">VIP：</label>--%>

                <%--<div class="controls">--%>
                <%--<select name="vip">--%>
                <%--<option value="-1">-请选择-</option>--%>
                <%--<option value="0">普通</option>--%>
                <%--<option value="1">VIP</option>--%>
                <%--<option value="2">单点</option>--%>
                <%--</select>--%>
                <%--</div>--%>
                <%--</div>--%>
                <div class="row">
                    <div class="control-group span8">
                        <label class="control-label">影视ID：</label>

                        <div class="controls">
                            <input type="text" name="_id" class="control-text">
                        </div>
                    </div>
                    <div class="control-group span8">
                        <label class="control-label">电影名：</label>

                        <div class="controls">
                            <input type="text" name="title" class="control-text">
                        </div>
                    </div>
                    <%--<div class="control-group span8">--%>
                    <%--<label class="control-label">渠道：</label>--%>

                    <%--<div class="controls">--%>
                    <%--<select name="mark">--%>
                    <%--<option value="">全部</option>--%>
                    <%--<c:forEach var="tt" items="${channels}">--%>
                    <%--<option value="${tt.mark}">${tt.title}</option>--%>
                    <%--</c:forEach>--%>
                    <%--</select>--%>
                    <%--</div>--%>
                    <%--</div>--%>
                    <div class="form-actions">
                        <div class="control-group span8">
                            <button id="btnSearch" type="submit" class="button button-primary">搜索</button>
                            <button style="margin-left: 50px" type="button" id="btnConfirm"
                                    class="button button-primary">EXECL导出
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </form>

    </div>
    <div class="search-grid-container">
        <div id="grid">
        </div>
    </div>

    <div id="content" class="hide">
        <form id="J_Form" class="form-horizontal" action="../edit">
            <input type="hidden" name="_id" value="0">
            <div class="row">
                <div class="control-group span14">
                    <label class="control-label"><s>*</s>影片名称</label>

                    <div class="controls">
                        <input name="title" type="text" data-rules="{required:true}"
                               class="input-large control-text">
                    </div>
                </div>
            </div>
            <div class="control-group span14">
                <label class="control-label"><s>*</s>mediaCode</label>

                <div class="controls">
                    <input name="mediaCode" type="text" data-rules="{required:true}"
                           class="input-large control-text">
                </div>
            </div>
            <div class="row">
                <div class="control-group span14">
                    <label class="control-label"><s>*</s>img：</label>

                    <div class="controls">
                        <input name="img" type="text" data-rules="{required:true}"
                               class="input-large control-text">
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="control-group span14">
                    <label class="control-label">演员：</label>

                    <div class="controls">
                        <input name="actor" type="text"
                               class="input-large control-text">
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="control-group span14">
                    <label class="control-label">导演：</label>

                    <div class="controls">
                        <input name="director" type="text"
                               class="input-large control-text">
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="control-group span14">
                    <label class="control-label">上映年份：</label>

                    <div class="controls">
                        <input name="years" type="text"
                               class="input-large control-text">
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="control-group span14">
                    <label class="control-label">影视评分：</label>

                    <div class="controls">
                        <input name="score" type="text"
                               class="input-large control-text">
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="control-group span14">
                    <label class="control-label">影视时长：</label>

                    <div class="controls">
                        <input name="playTimes" type="text" placeholder="单位为分钟"
                               class="input-large control-text">
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="control-group span14">
                    <label class="control-label">标签：</label>

                    <div class="controls">
                        <input name="tag" type="text" placeholder="如多个标签，用,隔开"
                               class="input-large control-text">
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="control-group span14">
                    <label class="control-label">地区：</label>

                    <div class="controls">
                        <input name="clime" type="text"
                               class="input-large control-text">
                    </div>
                </div>
            </div>
            <div class="row control-row4">
                <div class="control-group span14">
                    <label class="control-label"><s>*</s>描述：</label>

                    <div class="controls">
                        <textarea name="description" type="text" data-rules="{required:true}"
                                  class="input-large">
                            </textarea>
                    </div>
                </div>
            </div>
            <%--<div class="row control-row4">--%>
            <%--<div class="control-group span14">--%>
            <%--<label class="control-label">一句话描述：</label>--%>

            <%--<div class="controls">--%>
            <%--<textarea name="summary" type="text" class="input-large">--%>
            <%--</textarea>--%>
            <%--</div>--%>
            <%--</div>--%>
            <%--</div>--%>
            <%--<div class="control-group span8">--%>
            <%--<label class="control-label">VIP：</label>--%>

            <%--<div class="controls">--%>
            <%--<select name="vip">--%>
            <%--<option value="0">普通</option>--%>
            <%--<option value="1">VIP</option>--%>
            <%--<option value="2">单点</option>--%>
            <%--</select>--%>
            <%--</div>--%>
            <%--</div>--%>
            <%--<div class="row">--%>
            <%--<div class="control-group span14">--%>
            <%--<label class="control-label"><s>*</s>价格：</label>--%>

            <%--<div class="controls">--%>
            <%--<input name="price" type="text" data-rules="{required:true,number:true}"--%>
            <%--class="input-large control-text">--%>
            <%--</div>--%>
            <%--</div>--%>

            <%--</div>--%>

            <%--<div class="row">--%>
            <%--<div class="control-group span14">--%>
            <%--<label class="control-label"><s>*</s>权重：</label>--%>

            <%--<div class="controls">--%>
            <%--<input name="weight" type="text" data-rules="{required:true,number:true}"--%>
            <%--class="input-large control-text">--%>
            <%--</div>--%>
            <%--</div>--%>

            <%--</div>--%>
            <div class="row">
                <div class="control-group span14">

                    <div class="controls">
                        <c:forEach var="tt" items="${filmTypes}">
                            <label class="checkbox"><input name="filmTypes" type="checkbox" value="${tt}"/>${tt}</label>

                        </c:forEach>
                        <input type="hidden" name="filmTypes"/>
                    </div>
                </div>
            </div>
        </form>
    </div>

    <script type="text/javascript" src="/static/bui/js/jquery-1.8.1.min.js"></script>
    <script type="text/javascript" src="/static/bui/js/bui.js"></script>

    <script type="text/javascript" src="/static/jquery/table/tableExport.js"></script>
    <script type="text/javascript" src="/static/jquery/jquery.form.js"></script>

    <script type="text/javascript">


        BUI.use('common/search', function (Search) {
            var enumObj = {"1": "上线", "0": "下线", "-1": "停用"},
                    enumObj1 = {"1": "内地", "2": "港台", "3": "日韩", "4": "欧美", "5": "其他"};
            var editing = new BUI.Grid.Plugins.DialogEditing({
                contentId: 'content', //设置隐藏的Dialog内容
                autoSave: true, //添加数据或者修改数据时，自动保存
                triggerCls: 'btn-edit',
                height: 300
            });
            var columns = [
                {title: 'ID', width: 80, dataIndex: '_id'},
                {
                    title: '预览图', width: 60, renderer: function (value, obj) {
//                    return "<a href='" + obj.img + "' target='_Blank'><div style='width: 50px;height: 75px'><img style='width:100%;height=100%' src='" + obj.img + "'/></div></a>"
                }
                },
                {title: '名称', dataIndex: 'title'},
                {title: 'code值', dataIndex: 'mediaCode'},
                {title: '导演', dataIndex: 'director'},
                {title: '演员', dataIndex: 'actor', renderer: BUI.Grid.Format.cutTextRenderer(6)},
//                {title: '一句话描述', dataIndex: 'summary', renderer: BUI.Grid.Format.cutTextRenderer(5)},
                {title: '上映年份', width: 70, dataIndex: 'years'},
//                {title: '价格', width: 50, dataIndex: 'price'},
//                {title: '权重', width: 50, sortable: true, dataIndex: 'weight'},
                {title: '地区', width: 50, dataIndex: 'clime'},
                {title: '电影网分类', width: 150, dataIndex: 'mtypes'},
                {title: '互动分类', width: 150, dataIndex: 'filmTypes'},
                {title: '是否合作', width: 150, dataIndex: 'isonly', renderer: BUI.Grid.Format.enumRenderer(enumObj1)},
                {
                    title: '影片时长', width: 150, dataIndex: 'duration', renderer: function (value, obj) {
                    return obj.duration + '分钟'
//                    return Math.round(obj.duration / 60) + '分钟'
                }
                },
                {
                    title: '状态',
                    width: 50,
                    dataIndex: 'status',
                    renderer: BUI.Grid.Format.enumRenderer(enumObj)
                },
                {
                    title: '入库日期',
                    dataIndex: 'created',
                    width: 150,
                    renderer: BUI.Grid.Format.datetimeRenderer
                },
                {
                    title: '操作', width: 300, dataIndex: 'g', renderer: function (value, obj) {
                    var editStr1 = '<span class="grid-command btn-edit" title="修改">修改</span>';

//                    var editStr2 = '<span class="grid-command" title="详情">详情(敬请期待)</span>';
                    if (obj.status == -1) {
                        return editStr1
                    }
                    var info = "上线";
                    if (obj.status == 1) {
                        info = "下线"
                    }
                    var editStr = '<span class="grid-command btn-status" title="修改状态">' + info + ' </span>'
                    return editStr  + editStr1;
                }
                }
            ];

            var store = Search.createStore('/film/list.json', {
                        proxy: {
                            save: { //也可以是一个字符串，那么增删改，都会往那么路径提交数据，同时附加参数saveType
                                addUrl: './edit.json',
                                updateUrl: './edit.json'
                            }
                            ,
                            method: 'POST'
                        },
                        autoSync: true,
                        pageSize: 10
                    }),
                    gridCfg = Search.createGridCfg(columns, {
                        plugins: [editing, BUI.Grid.Plugins.AutoFit] // 插件形式引入多选表格
                    });

            var search = new Search({
                        store: store,
                        gridCfg: gridCfg
                    }),
                    grid = search.get('grid');

            grid.on('cellclick', function (ev) {
                var sender = $(ev.domTarget); //点击的Dom
                if (sender.hasClass('btn-status')) {
                    var record = ev.record;
                    $.ajax({
                                url: './changeStatus/' + record._id + ".json?status=" + record.status,
                                dataType: 'json',
                                type: "POST",
                                success: function (data) {
                                    if (data.code == 2000) {
                                        search.load()
                                    } else {
                                        BUI.Message.Alert("修改失败")
                                    }
                                }
                            }
                    )
                }
            })
        })
        ;

    </script>
    <!-- script end -->

    <script>
        //EXCEL功能模块
        $(document).ready(function () {
            $("#btnConfirm").click(function () {
                var _id = $("input[name=_id]").val();
                var title = $("input[name=title]").val();
                var status = $("select[name=status]").val();
                var vip = $("select[name=vip]").val();
                var rightEnd = $("input[name=rightEnd]").val();
                var sort = $("select[name=sort]").val();
                var clime = $("select[name=clime]").val();
                var hdType = $("select[name=hdType]").val();
                var turnoff = $("select[name=turnoff]").val();
                var mark = $("select[name=mark]").val();
                var ft = $("select[name=ft]").val();
                var isonly = $("select[name=isonly]").val();
                var url = "_id=" + _id + "&title=" + title + "&status=" + status + "&isonly=" + isonly + "&vip=" + vip + "&rightEnd=" + rightEnd + "&sort=" + sort + "&clime=" + clime + "&hdType=" + hdType + "&mark=" + mark + "&ft=" + ft + "&turnoff=" + turnoff + "&execl=execl";
                window.location = "/film/execl?" + url
            })
        })

        ;

    </script>
</div>
</body>
</html>
